package com.xiti.student.base.input;

import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import com.jtys.goods.entity.PlatformGoods;
import com.jtys.goods.entity.PlatformGoodsRatio;
import com.jtys.order.entity.PlatformOrder;
import com.jtys.order.entity.PlatformOrderDetail;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * <p>
 * 平台订单明细
 * </p>
 *
 * @author tangz
 * @since 2018-06-04
 */
@TableName("tb_o_platform_order_detail")
public class PlatformOrderDetailInput implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 组装OrderDetail
     */
    public static PlatformOrderDetail getNewPlatformOrderDetail(PlatformGoods goods, PlatformOrder order, PlatformGoodsRatio platformGoodsRatio, Date now) {
        PlatformOrderDetail orderDetail = new PlatformOrderDetail();
        orderDetail.setOrderId(order.getId());
        orderDetail.setOrderCode(order.getCode());
        orderDetail.setGoodsId(goods.getId());
        orderDetail.setGoodsName(goods.getName());
        orderDetail.setGoodsCode(goods.getCode());
        orderDetail.setPrice(goods.getPrice());
        orderDetail.setGoodsCount(1);
        orderDetail.setTotalAmount(goods.getPrice());
        if(platformGoodsRatio!=null){
            orderDetail.setRatio(platformGoodsRatio.getRatio());
            orderDetail.setRatioAmount(orderDetail.getTotalAmount().multiply(orderDetail.getRatio()));
        }
        orderDetail.setPartnerId(order.getPartnerId());
        orderDetail.setPartnerName(order.getPartnerName());
        orderDetail.setUserId(order.getUserId());
        orderDetail.setOrgId(order.getOrgId());
        return orderDetail;
    }

    /**
     * 平台订单明细id
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    /**
     * 平台订单id
     */
    private Long orderId;
    /**
     * 订单编号【冗余】
     */
    private String orderCode;
    /**
     * 平台商品id
     */
    private Long goodsId;
    /**
     * 商品名称
     */
    private String goodsName;
    /**
     * 商品编号
     */
    private String goodsCode;
    /**
     * 单个 价格
     */
    private BigDecimal price;
    /**
     * 商品数量
     */
    private Integer goodsCount;
    /**
     * 总金额
     */
    private BigDecimal totalAmount;
    /**
     * 实付金额(总金额-退款金额)
     */
    private BigDecimal payAmount;
    /**
     * 退款金额
     */
    private BigDecimal refundAmount;
    /**
     * 合伙人分成金额
     */
    private BigDecimal ratioAmount;
    /**
     * 分成比 小数
     */
    private BigDecimal ratio;
    /**
     * 合伙人id
     */
    private Long partnerId;
    /**
     * 合伙人姓名
     */
    private String partnerName;
    /**
     * 说明
     */
    private String remark;
    /**
     * 创建者账号
     */
    private String createdCode;
    /**
     * 创建者名称
     */
    private String createdName;
    /**
     * 创建时间
     */
    private Date createdTime;
    /**
     * 最后更新者账号
     */
    private String lastCode;
    /**
     * 最后更新者名称
     */
    private String lastName;
    /**
     * 最后更新时间
     */
    private Date lastTime;
    /**
     * 删除标记0未删除1已删除
     */
    private Integer deleteFlag;
    /**
     * 版本号
     */
    private Integer version;


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getOrderId() {
        return orderId;
    }

    public void setOrderId(Long orderId) {
        this.orderId = orderId;
    }

    public String getOrderCode() {
        return orderCode;
    }

    public void setOrderCode(String orderCode) {
        this.orderCode = orderCode;
    }

    public Long getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(Long goodsId) {
        this.goodsId = goodsId;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public String getGoodsCode() {
        return goodsCode;
    }

    public void setGoodsCode(String goodsCode) {
        this.goodsCode = goodsCode;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public Integer getGoodsCount() {
        return goodsCount;
    }

    public void setGoodsCount(Integer goodsCount) {
        this.goodsCount = goodsCount;
    }

    public BigDecimal getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(BigDecimal totalAmount) {
        this.totalAmount = totalAmount;
    }

    public BigDecimal getPayAmount() {
        return payAmount;
    }

    public void setPayAmount(BigDecimal payAmount) {
        this.payAmount = payAmount;
    }

    public BigDecimal getRefundAmount() {
        return refundAmount;
    }

    public void setRefundAmount(BigDecimal refundAmount) {
        this.refundAmount = refundAmount;
    }

    public BigDecimal getRatioAmount() {
        return ratioAmount;
    }

    public void setRatioAmount(BigDecimal ratioAmount) {
        this.ratioAmount = ratioAmount;
    }

    public BigDecimal getRatio() {
        return ratio;
    }

    public void setRatio(BigDecimal ratio) {
        this.ratio = ratio;
    }

    public Long getPartnerId() {
        return partnerId;
    }

    public void setPartnerId(Long partnerId) {
        this.partnerId = partnerId;
    }

    public String getPartnerName() {
        return partnerName;
    }

    public void setPartnerName(String partnerName) {
        this.partnerName = partnerName;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getCreatedCode() {
        return createdCode;
    }

    public void setCreatedCode(String createdCode) {
        this.createdCode = createdCode;
    }

    public String getCreatedName() {
        return createdName;
    }

    public void setCreatedName(String createdName) {
        this.createdName = createdName;
    }

    public Date getCreatedTime() {
        return createdTime;
    }

    public void setCreatedTime(Date createdTime) {
        this.createdTime = createdTime;
    }

    public String getLastCode() {
        return lastCode;
    }

    public void setLastCode(String lastCode) {
        this.lastCode = lastCode;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public Date getLastTime() {
        return lastTime;
    }

    public void setLastTime(Date lastTime) {
        this.lastTime = lastTime;
    }

    public Integer getDeleteFlag() {
        return deleteFlag;
    }

    public void setDeleteFlag(Integer deleteFlag) {
        this.deleteFlag = deleteFlag;
    }

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    @Override
    public String toString() {
        return "PlatformOrderDetail{" +
        ", id=" + id +
        ", orderId=" + orderId +
        ", orderCode=" + orderCode +
        ", goodsId=" + goodsId +
        ", goodsName=" + goodsName +
        ", goodsCode=" + goodsCode +
        ", price=" + price +
        ", goodsCount=" + goodsCount +
        ", totalAmount=" + totalAmount +
        ", payAmount=" + payAmount +
        ", refundAmount=" + refundAmount +
        ", ratioAmount=" + ratioAmount +
        ", ratio=" + ratio +
        ", partnerId=" + partnerId +
        ", partnerName=" + partnerName +
        ", remark=" + remark +
        ", createdCode=" + createdCode +
        ", createdName=" + createdName +
        ", createdTime=" + createdTime +
        ", lastCode=" + lastCode +
        ", lastName=" + lastName +
        ", lastTime=" + lastTime +
        ", deleteFlag=" + deleteFlag +
        ", version=" + version +
        "}";
    }


}
